<?php

class Kzend_Resource_Message extends Zend_Application_Resource_ResourceAbstract
{
    private $_messages = array();

    public function init()
    {
        $options = $this->getOptions();
        if (!isset($options['messageFilePath'])) {
            throw new Zend_Config_Exception("no set messageFilePath.");
        }

        if (file_exists($options['messageFilePath'])) {
            $configs = new Zend_Config_Ini($options['messageFilePath']);
            $this->_messages = $configs->toArray();
        }

        return $this;
    }

    public function get($messageId)
    {
        if (!isset($this->_messages[$messageId])) {
            throw new Zend_Config_Exception("Invalid messageId");
        }

        return $this->_messages[$messageId];
    }
}
